package com.lianxi.pojo.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.gson.Gson;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by wn
 * Date 2/1.
 * 素材库
 *
 * @author wn
 */
@Entity
@Table(name = "zxrm_material")
@Data
public class Material {


    /**


     素材id id;                                                id
     素材名称 name;                                       name
     操作人id operateUserId;                             uploaderId
     标注 note;                                           note
     素材作者  author;                                     author
     操作时间 operateTime;                                 uploadTime
     文件大小 fileSize;                                    size
     宽高 widthHeight;                                    width   height
     状态值 status;                                        deleted
     文件地址 src;                                         url
     标签词 keyWord;                                      keyword
     缩略图 thumbnail;                                    videoImg
     操作类型名称 materialTypeName;                         fileType
     素材类型 materialType;                                fileType
     文件类型 mimeType;                                     suffix

     操作人名字 operateUsername;
     新闻id newsId;
     转码状态 transCodingStatus;
     private String time; 时长，s   (已添加)

     新增：
     private int depId; 组织机构id，由上传人决定
     private String fileName; 资料名称  不再存储后缀
     private int catalogId; 一级分类Id
     private int catalog2Id; 二级分类id
     private String time; 时长，s

     */



    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(name = "id", value = "素材id")
    private int id;

    @Column(name = "old_material_id")
    @ApiModelProperty(name = "oldMaterialId", value = "老系统中素材的Id,用于识别与其他表的关联关系")
    private String oldMaterialId;


    @ApiModelProperty(name = "name", value = "素材名称")
    private String name = "";

    @ApiModelProperty(name = "fileName", value = "文件名，上传返回的文件名")
    @Column(name = "file_name")
    private String fileName;

    @ApiModelProperty(name = "file_path", value = "文件名，上传返回的文件名")
    @Column(name = "file_path")
    private String filePath;

    @JsonIgnore
    @Column(name = "operate_user_id", columnDefinition = "INT DEFAULT 0")
    @ApiModelProperty(name = "operateUserId", value = "操作人id")
    private int operateUserId;

    @Column(name = "operate_username")
    @ApiModelProperty(name = "operateUsername", value = "操作人名字")
    private String operateUsername = "";

    /**
     * 素材类型
     */
    @Column(columnDefinition = "INT DEFAULT 0")
    @ApiModelProperty(value = "素材类型（-1: 全部、0：图片、1：文件、2：视频、3：音频）", required = true)
    private int type;


    @Column(name = "label")
    @ApiModelProperty(name = "label", value = "素材标签")
    private String label="";

    @ApiModelProperty(name = "note", value = "标注")
    private String note = "";

    @ApiModelProperty(name = "author", value = "素材作者")
    private String author = "";


    @JsonIgnore
    @Column(name = "upload_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(name = "uploadTime", value = "操作时间")
    private Date uploadTime;

    @JsonIgnore
    @Column(name = "file_size")
    @ApiModelProperty(name = "fileSize", value = "文件大小")
    private long fileSize;


    @Column(name = "site_id")
    @ApiModelProperty(name = "siteId", value = "站点")
    private String siteId = "";

    @Column(name = "width")
    @ApiModelProperty(name = "width", value = "宽度")
    private String width = "";

    @Column(name = "height")
    @ApiModelProperty(name = "height", value = "高度")
    private String height = "";

    @JsonIgnore
    @Column(name = "operate_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(name = "operateTime",value = "操作时间")
    private Date operateTime;


    @JsonIgnore
    @Column(columnDefinition = "INT DEFAULT 0")
    @ApiModelProperty(name = "status",value = "状态值")
    private int status = 1;

    @ApiModelProperty(name = "src", value = "文件地址")
    private String src = "";

    @JsonIgnore
    @Column(name = "key_word")
    @ApiModelProperty(name = "keyWord", value = "标签词")
    private String keyWord = "";

    @ApiModelProperty(name = "thumbnail", value = "缩略图")
    private String thumbnail = "";


    @Column(name = "duration", columnDefinition = "INT DEFAULT 0")
    @ApiModelProperty(value = "时长，s")
    private Long duration = 0L;


    @Transient
    private String materialType = "";
    @Transient
    private String materialTypeName = "";


    /**
     * 素材后缀
     */
    @ApiModelProperty(value = "素材后缀", required = true)
    private String suffix;

    /**
     * 如果素材是从新闻中传过来的，传入新闻id，不是无须传入id
     */
    @JsonIgnore
    @Column(columnDefinition = "INT DEFAULT 0", name = "news_id")
    @ApiModelProperty(name = "newsId", value = "新闻id")
    private int newsId = 0;

    @Column(name = "trans_coding_status", columnDefinition = "INT DEFAULT 1")
    @ApiModelProperty(name = "transCodingStatus", value = "转码状态")
    private int transCodingStatus;

    @Column(name = "mime_type")
    @ApiModelProperty(name = "mimeType",value = "文件类型")
    private String mimeType = "";

    @Override
    public String toString() {
        return new Gson().toJson(this);
    }

}
